function gNa = gradTriangleBasisFunctions(Xa,x)
% this function computes the triangle basis functions at x (P1 element)
% Xa: Corner points of the triangle

A = TriangleArea(Xa);

A = 0.5/A;

xx=x(1);
yy=x(2);

x1=Xa(1,1);    y1=Xa(1,2);
x2=Xa(2,1);    y2=Xa(2,2);
x3=Xa(3,1);    y3=Xa(3,2);

gN1x = A*(y2-y3);

gN2x = A*(y3-y1);

gN3x = A*(y1-y2);

gN1y = A*(x3-x2);

gN2y = A*(x1-x3);

gN3y = A*(x2-x1);

gNa = [gN1x gN2x gN3x ; gN1y gN2y gN3y]';

